#include<bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std;

struct ty {
	string name;
	int score;
};

bool cmp(ty x, ty y) {
	return x.name < y.name;
}
signed main() {
	int n;
	cin >> n;
	ty a[n + 10];
	int sum = 0;
	
	for(int i = 0; i < n; i ++ ) {
		cin >> a[i].name >> a[i].score;
		sum += a[i].score;
	}
	sort(a, a + n, cmp);
	int t = sum % n;
//	cout << t << endl;
	cout << a[t].name << endl;
	return 0;
}
